﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _06QuadraticEquation
{
    class _06QuadraticEquation
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the three coefficients a, b and c (ax^2+bx+c=0):");
            Console.Write("a = ");
            string firstValue = Console.ReadLine();
            double a = double.Parse(firstValue);
            Console.Write("b = ");
            string secondValue = Console.ReadLine();
            double b = double.Parse(secondValue);
            Console.Write("c = ");
            string thirdValue = Console.ReadLine();
            double c = double.Parse(thirdValue);

            double disc = (Math.Pow(b, 2) - (4 * a * c));
            double singleRoot = (-b) / (2 * a);

            if (disc < 0)
            {
                Console.WriteLine("No real roots!");
            }
            else if (disc == 0)
            {
                Console.WriteLine("The equation has one root and it is {0}", singleRoot);
            }
            else if (disc > 0)
            {
                double x1 = (-b + Math.Sqrt(disc)) / (2 * a);
                double x2 = (-b - Math.Sqrt(disc)) / (2 * a);
                Console.WriteLine("The roots are {0:0.00000} and {1:0.00000}.", x1, x2);
            }
            Console.ReadLine();
        }
    }
}
